import random

user_agent_pc = [
    # 谷歌
    'Mozilla/5.0.html (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.html.2171.71 Safari/537.36',
    'Mozilla/5.0.html (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.html.1271.64 Safari/537.11',
    'Mozilla/5.0.html (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.html.648.133 Safari/534.16',
    # 火狐
    'Mozilla/5.0.html (Windows NT 6.1; WOW64; rv:34.0.html) Gecko/20100101 Firefox/34.0.html',
    'Mozilla/5.0.html (X11; U; Linux x86_64; zh-CN; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10',
    # opera
    'Mozilla/5.0.html (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.html.2171.95 Safari/537.36 OPR/26.0.html.1656.60',
    # qq浏览器
    'Mozilla/5.0.html (compatible; MSIE 9.0.html; Windows NT 6.1; WOW64; Trident/5.0.html; SLCC2; .NET CLR 2.0.html.50727; .NET CLR 3.5.30729; .NET CLR 3.0.html.30729; Media Center PC 6.0.html; .NET4.0C; .NET4.0E; QQBrowser/7.0.html.3698.400)',
    # 搜狗浏览器
    'Mozilla/5.0.html (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.html.963.84 Safari/535.11 SE 2.X MetaSr 1.0.html',
    # 360浏览器
    'Mozilla/5.0.html (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.html.1599.101 Safari/537.36',
    'Mozilla/5.0.html (Windows NT 6.1; WOW64; Trident/7.0.html; rv:11.0.html) like Gecko',
    # uc浏览器
    'Mozilla/5.0.html (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.html.2125.122 UBrowser/4.0.html.3214.0.html Safari/537.36',
    "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
    "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-us) AppleWebKit/534.50 (KHTML, like Gecko) Version/5.1 Safari/534.50",
    "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0",
    "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; InfoPath.3; rv:11.0) like Gecko",
    "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
    "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)",
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
    "Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
    "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; en) Presto/2.8.131 Version/11.11",
    "Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11",
    "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon 2.0)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; TencentTraveler 4.0)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; The World)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SE 2.X MetaSr 1.0; SE 2.X MetaSr 1.0; .NET CLR 2.0.50727; SE 2.X MetaSr 1.0)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; 360SE)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Avant Browser)",
    "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)",
    "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5",
    "Mozilla/5.0 (iPod; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5",
    "Mozilla/5.0 (iPad; U; CPU OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5",
    "Mozilla/5.0 (Linux; U; Android 2.3.7; en-us; Nexus One Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
    "MQQBrowser/26 Mozilla/5.0 (Linux; U; Android 2.3.7; zh-cn; MB200 Build/GRJ22; CyanogenMod-7) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
    "Opera/9.80 (Android 2.3.4; Linux; Opera Mobi/build-1107180945; U; en-GB) Presto/2.8.149 Version/11.10",
    "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13",
    "Mozilla/5.0 (BlackBerry; U; BlackBerry 9800; en) AppleWebKit/534.1+ (KHTML, like Gecko) Version/6.0.0.337 Mobile Safari/534.1+",
    "Mozilla/5.0 (hp-tablet; Linux; hpwOS/3.0.0; U; en-US) AppleWebKit/534.6 (KHTML, like Gecko) wOSBrowser/233.70 Safari/534.6 TouchPad/1.0",
    "Mozilla/5.0 (SymbianOS/9.4; Series60/5.0 NokiaN97-1/20.0.019; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebKit/525 (KHTML, like Gecko) BrowserNG/7.1.18124",
    "Mozilla/5.0 (compatible; MSIE 9.0; Windows Phone OS 7.5; Trident/5.0; IEMobile/9.0; HTC; Titan)",
    "UCWEB7.0.2.37/28/999",
    "NOKIA5700/ UCWEB7.0.2.37/28/999",
    "Openwave/ UCWEB7.0.2.37/28/999",
    "Mozilla/4.0 (compatible; MSIE 6.0; ) Opera/UCWEB7.0.2.37/28/999",
    # iPhone 6：
    "Mozilla/6.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/8.0 Mobile/10A5376e Safari/8536.25"]


def get_user_agent_pc():
    """
    返回请求搜索页面请求的ua
    :return: 返回请求搜索页面请求的ua
    """
    return {
        'User-Agent': random.choice(user_agent_pc),
        # 'cookie':'__jdu=56171293; shshshfpa=7fffdeb7-cf79-59dd-67c8-ab8624ebec1b-1620280517; shshshfpb=sNkTy%2FTMexuUFgEg3qDBnog%3D%3D; user-key=66be2699-cfaa-4664-8e65-f2f644f2891f; qrsc=3; rkv=1.0; pinId=Q-wxhgRRXkB4mSiLwi2ENbV9-x-f3wj7; pin=jd_4d67a4592377b; unick=jd_136979ujt; ceshi3.com=000; _tp=e0sgSBYaRpcpNV3dAX6QEz1%2BCa%2FZZ5OTqLkrxAzsN8A%3D; _pst=jd_4d67a4592377b; areaId=6; ipLoc-djd=6-303-304-0; unpl=V2_ZzNtbUBURRIhW09XeB5eVmJTG19KB0cdcQpBUn4fCQBuAREPclRCFnUUR1BnGV8UZwYZXkFcQhRFCEdkeBBVAWMDE1VGZxBFLV0CFSNGF1wjU00zQwBBQHcJFF0uSgwDYgcaDhFTQEJ2XBVQL0oMDDdRFAhyZ0AVRQhHZH8eXANnABpfcmdEJUU4RVR4H1wGVwIiXHIVF0lyCUBQexARAWADFF1BX0EldDhF; __jdv=76161171|baidu-pinzhuan|t_288551095_baidupinzhuan|cpc|0f3d30c8dba7459bb52f2eb5eba8ac7d_0_3276eb82263b4a839a59536747d4832c|1620800521250; PCSYCityID=CN_330000_330100_0; __jda=122270672.56171293.1620280513.1622002310.1622004380.53; __jdc=122270672; shshshfp=67ba12dfeaf6e7c783839f946ef32a05; wlfstk_smdl=9enhqz7l5fc7xlk951i2ffvol5mievto; logintype=wx; npin=jd_4d67a4592377b; thor=6EE7813FFEF8CC9A9434FC31BBE87F086814D612B58C9C6A20A60F783FB7714E483664C46737E4FA5C1480F246776691E38F9AAC56A65A700C05EB148FA89B3AA3F82405691B558248A097D418D4C804ED36B9D14E9323B19A2444C5154E571979AF0BFFD2FDF7E5B98802E64720D2805C3536A717C8037C1771BF09005688C6C05DFB09057FD013AAA70E75536552D3EFF16CE78733EDAF729E8B1340973FAA; __jdb=122270672.24.56171293|53.1622004380; shshshsID=1c048f3ffc9ce15fbbc58395afdf1140_22_1622007261939; 3AB9D23F7A4B3C9B=5TX52GHMM2E5BEBMZUQHYZ3KQAKBVGNG2G2V4GH2RR3EY2EFNAGIHSNTHEYZSLYGZK3IPNZLKAUGKIXXOEJNFL6UTI'
        #  'Cookie':'thor=6EE7813FFEF8CC9A9434FC31BBE87F086814D612B58C9C6A20A60F783FB7714E73A1B0D7CE745FFF942057AE1D47F5E4485FD767FB520F89144910F677840B1E0B5EA3C82B06A7755DF17762B6B3A93FE1B632C42D3F9BB03E1B43F3572AE2B84130AA0AFBB2EBDD2A5576F24EEBAA80FC3881E5427CA350765B93A886FD165C71BA24B66278CF84253B482947541D9CAFAA0E00B61EF4E5690D5907BF8A2969',
        # 'cookie':'pinId=Q-wxhgRRXkB4mSiLwi2ENbV9-x-f3wj7; user-key=2a5db057-ec9a-4451-8565-6f9e3d7712e6; __jdu=16220117885551004913237; ipLoc-djd=15-1213-3038-59931; shshshfp=a1063368fcb6cea36dd3df823b3a0842;shshshsID=c4cd2fe6311c7ddb9e80adc7ff3d49e4_3_1622096969770; __jda=122270672.16220117885551004913237.1622011789.1622090306.1622095554.9; __jdb=122270672.9.16220117885551004913237|9.1622095554; __jdc=122270672; 3AB9D23F7A4B3C9B=5TX52GHMM2E5BEBMZUQHYZ3KQAKBVGNG2G2V4GH2RR3EY2EFNAGIHSNTHEYZSLYGZK3IPNZLKAUGKIXXOEJNFL6UTI',
    }


def get_json_user_agent_pc():
    """
    返回请求json数据的ua
    :return: 返回请求json数据的ua
    """
    num = random.randint(1, 3)
    if num == 1:
        json_user_agent = {
            'User-Agent': random.choice(user_agent_pc),
        }
    if num == 2:
        json_user_agent = {
            'User-Agent': random.choice(user_agent_pc),
            'cookie': '__jdv=76161171|direct|-|none|-|1622011788556; shshshfpb=sNkTy%2FTMexuUFgEg3qDBnog%3D%3D; shshshfpa=7fffdeb7-cf79-59dd-67c8-ab8624ebec1b-1620280517; _pst=jd_4d67a4592377b; unick=jd_136979ujt; pin=jd_4d67a4592377b; _tp=e0sgSBYaRpcpNV3dAX6QEz1%2BCa%2FZZ5OTqLkrxAzsN8A%3D; pinId=Q-wxhgRRXkB4mSiLwi2ENbV9-x-f3wj7; user-key=2a5db057-ec9a-4451-8565-6f9e3d7712e6; __jdu=16220117885551004913237; areaId=3; ipLoc-djd=3-51035-39620-0; __jdc=122270672; wxa_level=1; jxsid=16221100254418598272; webp=1; mba_muid=16220117885551004913237; visitkey=44533314773034195; jxsid_s_u=https%3A//item.m.jd.com/product/68690455590.html; sc_width=1920; equipmentId=5TX52GHMM2E5BEBMZUQHYZ3KQAKBVGNG2G2V4GH2RR3EY2EFNAGIHSNTHEYZSLYGZK3IPNZLKAUGKIXXOEJNFL6UTI; deviceOSVersion=; deviceOS=; deviceName=Chrome; deviceVersion=90.0.4430.212; fingerprint=843f5a70db302466c671ab0a593c2e89; sk_history=68690455590%2C; __jda=122270672.16220117885551004913237.1622011789.1622158201.1622164443.16; wq_logid=1622165281.2060225143; retina=1; cid=9; wqmnx1=MDEyNjM1MGg6ZWptZDY0MGw1NDNNbDBuIDBXOylsSzMgTWllIG0uMzJhMzFGZmFhQjRRRVMpRilI; mba_sid=16221652824776117284206316358.1; __wga=1622165282893.1622165282893.1622110026075.1622110026075.1.2; PPRD_P=UUID.16220117885551004913237-LOGID.1622165282901.1397747255; jxsid_s_t=1622165282939; __jd_ref_cls=MDownLoadFloat_AppArouseA1; shshshfp=1306a6a18a815242e5ef63b3a76badc5; shshshsID=627cdea0ff1dc7f9bb64844f7842af38_16_1622166648764; __jdb=122270672.16.16220117885551004913237|16.1622164443; 3AB9D23F7A4B3C9B=5TX52GHMM2E5BEBMZUQHYZ3KQAKBVGNG2G2V4GH2RR3EY2EFNAGIHSNTHEYZSLYGZK3IPNZLKAUGKIXXOEJNFL6UTI'
        }
    else:
        json_user_agent = {
            'User-Agent': random.choice(user_agent_pc),
            'cookie': '__jdu=2037093595; shshshfpa=d329595e-caad-e253-239d-59b7745d7d5f-1597050594; shshshfpb=vA3z1jOADTTsIo2NfTPCU%2Fw%3D%3D; areaId=15; ipLoc-djd=15-1213-1214-0; PCSYCityID=CN_330000_330100_330110; pinId=Q-wxhgRRXkB4mSiLwi2ENbV9-x-f3wj7; pin=jd_4d67a4592377b; unick=jd_136979ujt; ceshi3.com=000; _tp=e0sgSBYaRpcpNV3dAX6QEz1%2BCa%2FZZ5OTqLkrxAzsN8A%3D; _pst=jd_4d67a4592377b; unpl=V2_ZzNtbUMFQhElAUEGLE5VUmIHRw4RA0oXfQpPXSgaWgM1URMKclRCFnUUR1BnGlsUZAEZWEZcQxBFCEdkexhdBGYCEFpBU3NMJVZGV3lFFzVXABJtQlZzFnQKQFVzG1gNYzMiWnJncxRFCXZVS1IyBCoAE19EVksXcQBCZHopXw%3d%3d; __jdv=76161171|www.hao123.com|t_1000003625_hao123mz|tuiguang|0c05a86cff8f45dbbe839388b277cc0f|1622043914819; __jdc=122270672; shshshfp=632078cf6ae07b2a3ab44a3cfe7c51bf; __jda=122270672.2037093595.1597050592.1622126966.1622157771.20; 3AB9D23F7A4B3C9B=MBJKNKEVTCNOYZHREDJ2B64KSHZGNSURLA2LARSYF3WJUCJYIAND3MNOW6XDGLJN47USZP62IAJR6DUQTOF53W52BM'
        }
    return json_user_agent
